package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.SignatureCallbackRecordEntity;
import com.yuexunit.finance.seal.entity.lexion.SealTypeEnum;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
*@version 创建时间：2017年9月21日 上午10:15:11
*@author wenwenlong
*类说明
*/
@Implements(SignatureCallbackRecordService.class)
public class SignatureCallbackRecordServiceImpl implements SignatureCallbackRecordService {

	@Override
	public Long createSignatureCallbackRecord(SignatureCallbackRecordEntity entity) {
		PersistUtil.insert(entity);
		return entity.getRecordId();
	}

	@Override
	public List<SignatureCallbackRecordEntity> inquirySignatureCallbackRecord(Long enterpriseId,
			Integer sealType, Integer recordType) {
		DetachedCriteria criteria = DetachedCriteria.forClass(SignatureCallbackRecordEntity.class);
		if(enterpriseId != null && enterpriseId > 0) {
			criteria.add(Restrictions.eq("enterpriseId", enterpriseId));
		}
		if(sealType != null) {
			criteria.add(Restrictions.eq("sealType", SealTypeEnum.valueOf(sealType)));
		}
		if(recordType != null) {
			criteria.add(Restrictions.eq("recordType", recordType));
		}
		return PersistUtil.get(criteria);
	}

}
